<template>
  <div>
    <script :id="id" type="text/plain"></script>
  </div>
</template>

<script>
  import ueditor from 'ueditor'
  export default {
    name: 'ueditor',
    props: {
      id: {
        type: String,
        default: 'editor'
      },
      config: {
        type: Object
      }
    },
    data () {
      return {
        editor: null
      }
    },
    mounted () {
      // 初始化UE
      const that = this
      that.editor = ueditor.delEditor(that.id)
      that.editor = ueditor.getEditor(that.id, that.config)
    },
    destoryed () {
      this.editor.destory()
    },
    methods: {
      getUEContent: function () {
        return this.editor.getContent()
      },
      getContentTxt: function () {
        return this.editor.getContentTxt()
      },
      getOpt: function (opt) {
        return this.editor.getOpt(opt)
      },
      isServerConfigLoaded: function () {
        return this.editor.isServerConfigLoaded()
      },
      loadServerConfig: function () {
        return this.editor.loadServerConfig()
      }
    }
  }
</script>
